<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Crear un nuevo vehiculo</title>
    <meta name="layout" content="main">
  </head>
  <body>
    <br>
  <g:link class="list" action="newVehicle">
    <div class="tabSelected">
      Vehicles
    </div>
  </g:link>
  <g:link class="list" action="edit" id="${session.data.id}">
    <div class="tabNoSelected">
      Edit My data
    </div>
  </g:link>
  <g:link class="list" action="logout" controller="LogIn">
    <div class="tabNoSelected">Log Out</div>
  </g:link>
  <div class="tabContent"> 
      <g:link class="list" action="newVehicle">
        <div class="tabSelected">
          New
        </div>
      </g:link>
      <g:link class="list" action="listVehicle" >
        <div class="tabNoSelected">
          List
        </div>
      </g:link>
    </div>
  <hr>
  <div id="create-vehicle" class="content scaffold-create" role="main">
    <h1>Create New Vehicle</h1>
    <g:if test="${flash.message}">
      <div class="message" role="status">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${vehicleInstance}">
      <ul class="errors" role="alert">
        <g:eachError bean="${vehicleInstance}" var="error">
          <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
        </g:eachError>
      </ul>
    </g:hasErrors>
    <g:form action="saveVehicle" >
      <fieldset class="form">

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'licensePlate', 'error')} required">
          <label for="licensePlate">
            <g:message code="vehicle.licensePlate.label" default="License Plate" />
            <span class="required-indicator">*</span>
          </label>
          <g:textField name="licensePlate" required="" value="${vehicleInstance?.licensePlate}"/>
        </div>
        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'confirmLicensePlate', 'error')} required">
                <label for="confirmLicensePlate">
                        <g:message code="vehicle.confirmLicensePlate.label" default="Confirm License Plate" />
                        <span class="required-indicator">*</span>
                </label>
                <g:textField name="confirmLicensePlate" required="" value="${vehicleInstance?.confirmLicensePlate}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'serialNumber', 'error')} required">
          <label for="serialNumber">
            <g:message code="vehicle.serialNumber.label" default="Serial Number" />
            <span class="required-indicator">*</span>
          </label>
          <g:textField name="serialNumber" required="" value="${vehicleInstance?.serialNumber}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'policyNumber', 'error')} required">
          <label for="policyNumber">
            <g:message code="vehicle.policyNumber.label" default="Policy Number" />
            <span class="required-indicator">*</span>
          </label>
          <g:textField name="policyNumber" required="" value="${vehicleInstance?.policyNumber}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'mileage', 'error')} required">
          <label for="mileage">
            <g:message code="vehicle.mileage.label" default="Mileage" />
            <span class="required-indicator">*</span>
          </label>
          <g:textField name="mileage" required="" value="${vehicleInstance?.mileage}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'fuelType', 'error')} required">
          <label for="fuelType">
            <g:message code="vehicle.fuelType.label" default="Fuel Type" />
            <span class="required-indicator">*</span>
          </label>
          <g:textField name="fuelType" required="" value="${vehicleInstance?.fuelType}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'carMake', 'error')} ">
          <label for="carMake">
            <g:message code="vehicle.carMake.label" default="Car Make" />

          </label>
          <g:textField name="carMake" value="${vehicleInstance?.carMake}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'carModel', 'error')} ">
          <label for="carModel">
            <g:message code="vehicle.carModel.label" default="Car Model" />

          </label>
          <g:textField name="carModel" value="${vehicleInstance?.carModel}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'colour', 'error')} ">
          <label for="colour">
            <g:message code="vehicle.colour.label" default="Colour" />

          </label>
          <g:textField name="colour" value="${vehicleInstance?.colour}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'customer', 'error')} required">
          <label for="customer">
            <g:message code="vehicle.customer.label" default="Customer" />
            <span class="required-indicator">*</span>
          </label>
          <g:select id="customer" name="customer.id" from="${customers}" optionKey="id" optionValue="name" required="" value="${vehicleInstance?.customer?.id}" class="many-to-one"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'cylinderNumber', 'error')} ">
          <label for="cylinderNumber">
            <g:message code="vehicle.cylinderNumber.label" default="Cylinder Number" />

          </label>
          <g:textField name="cylinderNumber" value="${vehicleInstance?.cylinderNumber}"/>
        </div>

        <div class="fieldcontain ${hasErrors(bean: vehicleInstance, field: 'type', 'error')} ">
          <label for="type">
            <g:message code="vehicle.type.label" default="Type" />

          </label>
          <g:textField name="type" value="${vehicleInstance?.type}"/>
        </div>
      </fieldset>
      <fieldset class="buttons">
        <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
      </fieldset>
    </g:form>
  </div>
</body>
</html>
